package ysw.action;
import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import ysw.vo.*;
import ysw.jdbc.FixJdbc;
import org.apache.struts2.ServletActionContext;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

public class FixAction extends ActionSupport {
  private static final long serialVersionUID = 1L;
	private Fix fix;

    public Fix getFix() {
        return fix;
    }

    public void setFix(Fix fix) {
        this.fix = fix;
    }

  
  
    
  private List<Fix>  fixList;

      
    

 public String execute() throws Exception{
  
    FixJdbc fixJ=new FixJdbc();
    
     //fix.setFid(fix.getFid());
     fix.setFtime(fix.getFtime());
     fix.setFtype(fix.getFtype());
     fix.setCarnumber(fix.getCarnumber());
     fix.setCid(fix.getCid());
     fix.setCname(fix.getCname());
     fix.setWorktime(fix.getWorktime());
     fix.setPrice(fix.getPrice());
     fix.setState(fix.getState());
     
      
     fixJ.addFix(fix);
       
        return SUCCESS;
    }

 public String showAllFix()throws Exception{
   
	Fix fix1=new Fix();
        FixJdbc fixJ=new FixJdbc();
        try{
            fixList=fixJ.showFix();
        }catch(SQLException e){
            e.printStackTrace();
        }
   
	Map request=(Map)ActionContext.getContext().get("request");
        request.put("fixList",fixList);
  
        return SUCCESS;
    }
 public String showOneFix() throws Exception{
   	Fix fix1=new Fix();
        FixJdbc fixJ=new FixJdbc();
     fix1=fixJ.showOneFix(fix.getFid());

     Map request=(Map)ActionContext.getContext().get("request");
     request.put("fix1",fix1);
     return SUCCESS;


}
 public String updateSaveFix() throws Exception{
    FixJdbc fixJ=new FixJdbc();
   
      fix.setFid(fix.getFid());
     fix.setFtime(fix.getFtime());
     fix.setFtype(fix.getFtype());
     fix.setCarnumber(fix.getCarnumber());
     fix.setCid(fix.getCid());
     fix.setCname(fix.getCname());
     fix.setWorktime(fix.getWorktime());
     fix.setPrice(fix.getPrice());
     fix.setState(fix.getState());
    
    fixJ.updateSaveFix(fix);
    return SUCCESS;
}
 
 
public String deleteFix()throws Exception{

    FixJdbc fixJ=new FixJdbc();
    fixJ.deleteFix(fix.getFid());
    System.out.println(fix.getFid()+"fix.getFid()");
    return SUCCESS;
    
}
}
